mat.C.all <- array(dim = c(34,34,4,4,n.subj))
i <- 1
for (s in list.subj) {
# --- load the confusion matrix
tmp.file <- os$path$join(path.root, s, "rd_to_rd_confmats.npz") %>%
np$load()
# --- crop around S0 (decoded stimulus)
mat.C.all[,,,,i] <- tmp.file$f[["arr_0"]][,71:104,71:104,,] %>%
apply(c(2,3,4,5), mean)
i <- i+1
}
mat.C.mean <- mat.C.all %>% apply(c(1,2,3,4), mean)
df.confusion <- matrix_to_df2(mat.C.mean[22,22,,], "from", "to", "p") %>%
mutate(label = paste0("a[",from,to,"]"))
df.confusion %>%
ggplot(aes(x = to, y = from, fill = p)) +
geom_tile(color = "firebrick3") +
geom_text(aes(label = label), parse = T, color = "firebrick3") +
scale_x_continuous(name = "predicted class", position = "top") +
scale_y_reverse(name = "true class") +
scale_fill_stepsn(name = "p",
colors = pals::brewer.greys(100),
# low = "white", high = "black",
labels = ~str_replace(., "^0.","."),
breaks = scales::pretty_breaks(6),
limits = c(.20,.30), oob = scales::squish) +
coord_equal(xlim = c(0.5,4.5), ylim = rev(c(0.5,4.5)),
expand = F, clip = "off") -> g.matC
matrix_to_df2(mat.T$MP, "from", "to", "p") %>%
mutate(label = paste0("a[",from,to,"]")) %>%
ggplot(aes(x = to, y = from, fill = p)) +
geom_tile(color = "firebrick3") +
geom_text(aes(label = label), parse = T, color = "firebrick3") +
scale_x_continuous(name = "to", position = "top") +
scale_y_reverse(name = "from") +
scale_fill_stepsn(name = "p",
colors = pals::brewer.greys(100),
labels = ~str_replace(., "^0.","."),
breaks = scales::pretty_breaks(6),
limits = c(.0,.50), oob = scales::squish) +
coord_equal(xlim = c(0.5,4.5), ylim = rev(c(0.5,4.5)),
expand = F, clip = "off") -> g.matT
((g.matT + labs(caption = "Transition matrix\n(midplus (MP) sequence)") +
guides(fill = guide_colorbar(barwidth = 0.5, ticks = F))) +
(g.matC + labs(caption = "Confusion matrix\n(group average, t=210ms)") +
guides(fill = guide_colorbar(barwidth = 0.5, ticks = F))) &
theme(plot.caption = element_text(size = 10),
axis.title = element_text(face = "italic"),
legend.box.spacing = unit(2,"mm"),
)
) +
plot_annotation(tag_levels = "a") -> g.supfig4
g.supfig4